//
//  EndingAnswerAlterView.m
//  ZHIDOU
//
//  Created by 向礼 on 2018/12/24.
//  Copyright © 2018 向礼. All rights reserved.
//

#import "EndingAnswerAlterView.h"

static EndingAnswerAlterView *_instance = nil;
@interface EndingAnswerAlterView()

@property (weak, nonatomic) IBOutlet UIButton *continueBtn;

@end

@implementation EndingAnswerAlterView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self = [[NSBundle mainBundle] loadNibNamed:@"EndingAnswerAlterView" owner:self options:nil].firstObject;
        self.frame = frame;
        self.autoresizingMask = NO; // 否则会根据父视图大小变化
    }
    return self;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0];
    _continueBtn.layer.cornerRadius = 44.5 * ZD_defaultScale/2;
    _continueBtn.layer.masksToBounds = YES;
    
//    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(actionButtonClicked:)];
//    [self.imageView addGestureRecognizer:tap];
}

+ (void)showAlter{
    if (!_instance) {
        _instance = [[EndingAnswerAlterView alloc] initWithFrame:(CGRect){0, 0, ZD_screenWidth, ZD_screenHeight}];
    }
    UIWindow *window = [UIApplication sharedApplication].delegate.window;
    [window addSubview:_instance];
    
    [UIView animateWithDuration:0.25 animations:^{
        _instance.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.7];
    }];
}

+ (void)dismiss {
    if (_instance) {
        [UIView animateWithDuration:0.15 animations:^{
            _instance.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0];
        } completion:^(BOOL finished) {
            [_instance removeFromSuperview];
            _instance = nil;
        }];
    }
}
- (IBAction)ContinueAction:(id)sender {
    
}
- (IBAction)EndAction:(id)sender {
    [EndingAnswerAlterView dismiss];
}

@end
